<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head><title>Liquid Chicken Demo: Dynamic Form Update with JavaScript</title>
<!-- License {{{
Liquid Chicken Demo: Dynamic Form Update with JavaScript License

This work is licensed under the MIT License
(http://www.opensource.org/licenses/mit-license.php).  Some libraries, images,
and other included works may be separately licensed.  See attribution or source
of those works for licensing terms.

Copyright (c) 2011 Kelly Setzer 

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

ADDITIONAL LICENSES
    * jQuery Javascript Library (c) 2010 The jQuery Project
        licensed under the MIT License
    * jQueryUI Javascript Library (c) 2010 The jQuery Project
        licensed under the MIT License
}}} -->

<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<link type="text/css" href="js_form_dynamic_update.css" rel="stylesheet" />
<script>

$(function() {
    // This handles the select box and digests multi-select
    $("#my-form-input-animal").change(function () {
        var str = "";
        $("select option:selected").each(function () {
            str += $(this).text() + " ";
        });
        $("#display-animal").text(str);
    });

    // Handle the text field using keyup()
    $("#my-form-input-howmany").keyup(function () {
        var text = $("#my-form-input-howmany").val();
        $("#display-howmany").text(text);
    });

    // Handle the cooked radio buttons
    $(":input[@name='ncooked']").change(function(){
        var text = $(":input[@name='ncooked']:checked").val();
        $("#display-cooked").text(text);
    });
});

</script>
</head>
<body>
<div id="container">
    <div class="display">
        <br />
        <form id="my-form" class="centered">
        <fieldset>
            <label for="my-form-input-howmany">How Many</label>
            <input type="text" size="5" id="my-form-input-howmany"/>
            <br/>

            <label for="my-form-input-cooked">Cooked</label><br />
            <input type="radio" name="ncooked" id="my-form-input-cooked" value="Burnt"/>Well Done<br />
            <input type="radio" name="ncooked" id="my-form-input-cooked" value="Overcooked"/>Medium Well<br />
            <input type="radio" name="ncooked" id="my-form-input-cooked" value="Sissified"/>Medium<br />
            <input type="radio" name="ncooked" id="my-form-input-cooked" value="Perfectly Cooked"/>Medium Rare<br />
            <input type="radio" name="ncooked" id="my-form-input-cooked" value="Live"/>Rare<br />
            <br/>

            <label for="my-form-input-animal">Animal</label>
            <select id="my-form-input-animal">
                <option selected> </option>
                <option>Cows</option>
                <option>Pigs</option>
                <option>Monkeys</option>
            </select>
            <br/>
        </fieldset>
        <div id="reset-button"><input type="reset" value="Reset" /></div>
        </form>
        <div id="your-order" class="big-text">Your order: 
            <span id="display-howmany"> </span> <span id="display-cooked"> </span> <span id="display-animal"> </span>
        </div>
        <div id="footer">(c)2011 Liquid Chicken Software.  View source for license.</div>
    </div>
</div>

</body>
</html>
